package cn.com.longfuinfo.wx.service.post;

import java.util.List;

import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import cn.com.longfuinfo.wx.common.OrderCode;
import cn.com.longfuinfo.wx.dao.BabyTitle;
import cn.com.longfuinfo.wx.dao.Goods;
import cn.com.longfuinfo.wx.dao.Store;
import cn.com.longfuinfo.wx.dao.UserLook;

/**
 * 产后恢复计划
 * @author yss
 */
public class PostRestService {
	
	/**
	 * 查询产后可体验商品列表
	 * @param titleCord
	 * @return
	 */
	
	public List<Record> findGoodsBytTitleCord(String titleCord,int wxUserid) {
		String sql="SELECT bo.id,bo.thumb,bo.name,cast(spec.marketPrice as char(11)) marketPrice,ifnull(bd.countnum,0) num,"
			+"bdd.orderState,spec.integral,spec.currency,spec.integCur_i,spec.integCur_c,spec.integralType,spec.integCur_iType"
			+" FROM t_bus_goods bo left join t_bus_goods_spec spec on spec.goodId=bo.id"
			+" left join (SELECT count(id) id,sum(countnum) countnum,goodsid FROM t_bus_order WHERE payState=2 GROUP BY goodsid) bd on bd.goodsid=bo.id"
			+" left join (SELECT orderState,goodsid,userid FROM t_bus_order WHERE payState=2 and orderState <>3 and userid='"+wxUserid+"' GROUP BY goodsid) bdd on bdd.goodsid=bo.id"
			+" where bo.state='2' and bo.titleCord  like '%"+titleCord+"%' "
			+" group by bo.id ORDER BY num DESC";
		return Db.find(sql);

	}
}
